﻿
function ShowStartTimeSelect(sender, args) {
    //$find('PopupStartDate').show();
}

function CheckSignUpDates(sender, args) {
    var offdate = GetSignOffDateTime();
    args.IsValid = true;
    if (offdate < new Date()) {
        args.IsValid = false;
        sender.errormessage = "报名截止时间不能早于现在。";
    }
    else if (offdate > GetStartDateTime()) {
        sender.errormessage = "报名截止时间不能晚于开始时间。";
        args.IsValid = false
    }
}

function GetSignOffDateTime()
{
    var edate = new Date($('.offdate').val());
    var ehour = $('.offhour').val();

    return new Date(edate.setHours(ehour, 0, 0));
}

function GetStartDateTime() {
    var instance = $('.startdate').data("datepicker");
    var sdate = $.datepicker.parseDate(instance.settings.dateFormat || $.datepicker._defaults.dateFormat, $('.startdate').val(), instance.settings);
    var shour = $('.starthour').val();
    var smin = $('.startmin').val();

    return new Date(sdate.setHours(shour, smin, 0));
}

function GetEndDateTime() {
    var instance = $('.enddate').data("datepicker");
    var edate = $.datepicker.parseDate(instance.settings.dateFormat || $.datepicker._defaults.dateFormat, $('.enddate').val(), instance.settings);
    var ehour = $('.endhour').val();
    var emin = $('.endmin').val();

    return new Date(edate.setHours(ehour, emin, 0));
}


function CheckActivityDates(sender, args) {

        args.IsValid = GetEndDateTime() > GetStartDateTime();
}

function CheckStartDate(sender, args) {
    args.IsValid = GetStartDateTime() > new Date();
}

function ConfirmCancelEdit() {
    if (confirm("真的要取消修改？")) {
        location.href = 'MyEvents.aspx';
    }
}